<?php
session_start();
require('../conn.php');
require('../functions.php');
require('admin.php');
$filename = "tx.xls";
header('Content-Type: application/vnd.ms-execl');
header('Content-Type: application/vnd.ms-excel; charset=utf-8');
header("Content-Disposition: attachment; filename=$filename");
header('Pragma: no-cache');
header('Expires: 0');
$day = date("Y-m-d", time());
$rows = $mysql->query("select * from `txdata` where `state`=0 order by `id` desc");
foreach ($rows as $row) {
    $realname = iconv('utf-8', 'gb2312', $row['realname']);
    if ($row['sx1'] !== '') {
        $sx1_money = $row['money'] * ($config['tc'] / 100);
        $arr_tx = array('uid' => $row['sx1'], 'aid' => '-1', 'title' => "下线会员ID：{$row['uid']}提现分成奖励", 'long' => '#', 'money' => $sx1_money, 'ip' => '', 'day' => $day, 'time' => time(),);
        $value = arr2s($arr_tx);
        $mysql->query("insert into `refererdata` {$value}");
        $mysql->execute("update `userdata` set `money`=`money`+{$sx1_money}, `income`=`income`+{$sx1_money} where `id`='{$row['sx1']}'");
    }
    echo $realname . "\t";
    echo $row['alipay'] . "\t";
    echo $row['money'] . "\t";
    echo '
';
}
$mysql->execute("update `txdata` set `state`=1 where `state`=0"); ?>